﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows8Accelerator.Core.Xaml.Html;

namespace Windows8Accelerator.Core.Xaml.Controls.RichText
{
    public class FormatVisitor : ControlVisitor
    {
        public FormatVisitor(SuperHtmlNode superHtmlNode, SuperHtmlNodeVisitor parentVisitor)
            : base(superHtmlNode, parentVisitor)
        {
            VisitChildren = true;
        }

        protected override void InternalVisitNode1(SuperHtmlNode htmlNode)
        {
            switch (htmlNode.TagName)
            {
                case "u":
                    {
                        var underline = RichTextFactoryBase.Instance.NewUnderline();
                        Results.Add(underline);
                        NewParent = underline;
                    }
                    break;
                case "b":
                case "strong":
                    TextFormat.Merge(State.BoldTextFormat);
                    break;
                case "em":
                case "i":
                    TextFormat.Merge(State.ItalicTextFormat);
                    break;
            }
        }
    }
}
